In a typical single-server setup, timestamps remain consistent; however, in a Ditto mesh where there are multiple Small Peer devices distributed across the network, each device may operate on its own time. This can lead to discrepancies where a document’s timestamp may seem ahead or documents created simultaneously have different timestamps.
INSERT
operation, in which the ISO-8601 timestamp is generated using new
Date().toISOString()
, and then the lastUpdatedAt
field is included in the newCar
object that gets inserted into the cars
collection:
ISO8601DateFormatter
as an extension on DateFormatter
— a common approach to extend the functionality of the DateFormatter
class — to handle ISO8601 dates, see the GitHub Gist > DateFormatter+docDictionary.swift.cars
collection where the timestamp
field value is greater than or equal to December 1, 2023, at midnight UTC: